package com.example.myapplication;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {
    private final String TAG="MyService";
    private MyBinder myBinder;

    @Override
    public void onCreate() {
        Log.e(TAG,"onCreate");
        super.onCreate();
        myBinder=new MyBinder();
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.e(TAG,"onBind");
        return myBinder;

    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.e(TAG,"onUnbind");
        return super.onUnbind(intent);
    }

    @Override
    public void onDestroy() {
        Log.e(TAG,"onDestory");
        super.onDestroy();
    }

    class MyBinder extends Binder{
        public void play(){
            Log.e("MyBinder","开始播放歌曲");
        }
        public void stop(){
            Log.e("MyBinder","停止播放歌曲");
        }
        public int cal1n(int n){
            return (1+n)*n/2;
        }

    }

}